###
 # @Author: Kilims Ye
 # @Date: 2020-08-11 11:57:05
 # @LastEditTime: 2021-03-31 09:43:30
 # @LastEditors: Kilims Ye
 # @Description: 通过scripty实现自动化deploy的工作流，爽得吖批
 # @FilePath: /react-mobile-seeds/script/deploy.sh
### 
#!/bin/sh
routeName=react-mobile-seeds

ssh root@10.0.17.114 'mkdir /home/app/'${routeName}''
ssh root@10.0.17.115 'mkdir /home/app/'${routeName}''

echo "Back up Start:"
nowDate=`date +%Y%m%d`
ssh root@10.0.17.114 'cd /bak && tar -cvf '${nowDate}'_'${routeName}'.tar /home/app/'${routeName}''
echo "Back up Finished"

echo "Clean Start:"
ssh -t root@10.0.17.114 rm -rf /home/app/${routeName}/*
ssh -t root@10.0.17.115 rm -rf /home/app/${routeName}/*
echo "Clean Finished"

echo "Upload:"
cd ./build
pwd
scp -r ./* root@10.0.17.115:/home/app/${routeName}
scp -r ./* root@10.0.17.114:/home/app/${routeName}
echo "Upload Finished"